package cn.lanqiao.facelogin.BaiDuFace;

import cn.lanqiao.facelogin.domain.LoginData;
import cn.lanqiao.facelogin.utils.GsonUtils;
import cn.lanqiao.facelogin.utils.HttpUtil;

import java.util.*;

/**
 * 人脸更新
 */
public class FaceUpdate {

    public static String m1(String base64, String uuid){
        // 请求url
        String url = "https://aip.baidubce.com/rest/2.0/face/v3/faceset/user/update";
        try {
//            String substring = base64.substring(22);
            Map<String, Object> map = new HashMap<>();
            map.put("image", base64);
            map.put("group_id", "FaceData");
            map.put("user_id", uuid);
            map.put("user_info", "cba");
            map.put("liveness_control", "NORMAL");
            map.put("image_type", "BASE64");
            map.put("quality_control", "LOW");

            String param = GsonUtils.toJson(map);

            // 注意这里仅为了简化编码每一次请求都去获取access_token，线上环境access_token有过期时间， 客户端可自行缓存，过期后重新获取。
            String accessToken = "[24.94404afc7895bfe710a18ba16ceced64.2592000.1648171231.282335-25549431]";

            String result = HttpUtil.post(url, accessToken, "application/json", param);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


}